﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace Tech4WPF_TestApp
{
    /// <summary>
    /// Interaction logic for StartMenu.xaml
    /// </summary>
    public partial class StartMenu : Window
    {
        #region Constructor

        /// <summary>
        /// Initializes a new instance of the <see cref="StartMenu"/> class.
        /// </summary>
        public StartMenu()
        {
            InitializeComponent();
        }

        #endregion Constructor

        #region Fields
        private List<Window> childWindows = new List<Window>();
        #endregion Fields

        #region Methods

        private void OnBtnKnobControlClick(object sender, RoutedEventArgs e)
        {
            Window knobControlTestWindow = new KnobControlTest();
            childWindows.Add(knobControlTestWindow);
            knobControlTestWindow.Show();
        }

        private void OnBtnChartControlClick(object sender, RoutedEventArgs e)
        {
            Window chartControlTestWindow = new ChartControlTest();
            childWindows.Add(chartControlTestWindow);
            chartControlTestWindow.Show();
        }

        private void OnBtnGaugeControlClick(object sender, RoutedEventArgs e)
        {
            Window gaugeControlTestWindow = new GaugeControlTest();
            childWindows.Add(gaugeControlTestWindow);
            gaugeControlTestWindow.Show();
        }

        protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
        {
            closeChildWindows();
            base.OnClosing(e);
        }

        private void closeChildWindows()
        {
            foreach (var childWindow in this.childWindows)
            {
                childWindow.Close();                   
            }
        }

        #endregion Methods
    }
}
